import axios from 'axios';

var commonOper = {
  showWarnAlert: function (params) {
    params.this.$confirm({
      title: params.title || '提示',
      content: params.message,
      okType: params.okType || 'primary',
      onOk() {
        params.successFunc && params.successFunc.call();
      },
      onCancel() { params.failFunc && params.failFunc.call(); },
    });
  },
  /** 显示系统通知 */
  Notification: function (params) {
    params.this.$notification.config({
      top: '65px'
    });
    params.this.$notification[params.type]({
      message: params.title,
      description: params.message,
    });
  },
  /**发送http post请求 */
  HttpPost: function (params) {

    axios.post(params.url, params.data, {
      headers: params.headers
    })
      .then(function (response) {
        params.successFunc && params.successFunc.call(params.this, response);
      })
      .catch(function (response) {
        params.failFunc && params.failFunc.call(this, response);
      });

  },
  /**发送http get请求 */
  HttpGet: function (params) {

    axios.get( params.url, params.data)
      .then(function (response) {
        params.successFunc && params.successFunc.call(params.this, response);
      })
      .catch(function (response) {
        params.failFunc && params.failFunc.call(this, response);
      });

  },
};
export default commonOper;